package com.ijiuchuang.jc_localization.view.fragment;

import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.ijiuchuang.jc_localization.R;
import com.ijiuchuang.jc_localization.contract.settings.SettsLocationContract;
import com.ijiuchuang.jc_localization.presenter.settings.SettsLocationPresenter;
import com.ijiuchuang.jc_localization.view.activity.FragmentActivity;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

/**
 * A simple {@link Fragment} subclass.
 */
public class SettsLocationFragment extends Fragment implements SettsLocationContract.View {

    @BindView(R.id.setts_location_scene_linear)
    LinearLayout sceneLinear;
    @BindView(R.id.setts_location_scene_text_name)
    TextView textScene;

    private SettsLocationContract.Presenter presenter;

    public SettsLocationFragment() {
        // Required empty public constructor
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        // Inflate the layout for this fragment
        View view = inflater.inflate(R.layout.fragment_setts_location, container, false);
        ButterKnife.bind(this, view);

        presenter = new SettsLocationPresenter(getActivity(), this);

        return view;
    }

    @Override
    public void onStart() {
        super.onStart();

        presenter.start();
    }

    @Override
    public void setPresenter(SettsLocationContract.Presenter presenter) {
        this.presenter = presenter;
    }

    @OnClick(R.id.setts_location_scene_linear)
    public void onClick() {
        Intent intent = new Intent(getActivity(), FragmentActivity.class);
        intent.putExtra(FragmentActivity.FRAGMENT_NAME, FragmentActivity.FRAGMENT_NAME_SETTS_MAP_LIST);
        startActivity(intent);
    }

    @Override
    public void setSceneName(String name) {
        textScene.setText(name);
    }
}
